package com.itstyle.seckill.common.designPattern.fangwenzhe;

import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;

public class Client {
    public static void main(String[] args) {
//        Candy candy = new Candy("小白兔奶糖", LocalDate.of(2019,1,1),20.01f);
//        IVisitor visitor = new Custor(LocalDate.of(2019,1,1));
//        visitor.visit(candy);

        // 三件商品加入购物车
        List<Acceptable> products = Arrays.asList(
                    new Candy("小黑兔奶糖", LocalDate.of(2018, 10, 1), 20.00f),
                    new Wine("猫泰白酒", LocalDate.of(2017, 1, 1), 1000.00f),
                    new Fruit("草莓", LocalDate.of(2018, 12, 26), 10.00f, 2.5f)
        );

        IVisitor discountVisitor = new Custor(LocalDate.of(2018, 1, 1));
        // 迭代购物车轮流结算
//        for (Product product : products) {
//                discountVisitor.visit(product);// 此处报错
//            }
        for (Acceptable product : products) {
            product.accept(discountVisitor);
        }
    }
}
